Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net Pdfsharp和Pdfsharp:如何利用migradoc和Pdfsharp使右侧白色面板响应?_.net_Pdfsharp_Migradoc - Fatal编程技术网

.net Pdfsharp和Pdfsharp:如何利用migradoc和Pdfsharp使右侧白色面板响应?

.net Pdfsharp和Pdfsharp:如何利用migradoc和Pdfsharp使右侧白色面板响应?,.net,pdfsharp,migradoc,.net,Pdfsharp,Migradoc,//---pdfSharp--------------------------- //-- migradoc---------- <code> Document document = new Document(); Section section = document.AddSection(); Paragraph paragraph = section.AddParagraph(); </code&g

//---pdfSharp---------------------------

//-- migradoc----------
    <code>
          Document document = new Document();
          Section section = document.AddSection();
          Paragraph paragraph = section.AddParagraph();
    </code>
//---渲染文档对象--------------------------------------------- //---这里的文档是包含pdfsharp文档中使用的所有数据的migradoc文档

MigraDoc.Rendering.DocumentRenderer docRenderer=新的DocumentRenderer(文档);
docRenderer.PrepareDocument();
//---长度标签
int leftPanelYaxis=0;
int RightPanelHeight=0;
尝试
{
//呈现段落。你可以用同样的方式呈现表格或形状。
渲染对象(gfx,XUnit.Fromcm(0.7),XUnit.Fromcm(0.5),“6cm”,名称);
渲染对象(gfx,XUnit.Fromcm(0.7),XUnit.Fromcm(2),“6cm”,大约);
渲染对象(gfx,XUnit.Fromcm(0.3),XUnit.Fromcm(2),“0.6cm”,关于Me_图标);
}

[ //---如何使这个右侧动态。migradoc有这个功能来实现这一点。但左侧面板是彩色和固定的,而右侧面板将是响应的。如何实现这一点。
当前,右面板上的数据溢出且重叠,因为它是一页。当我渲染Migradoc的对象时,它在pdfsharp文档上溢出。是否有其他方法可以解决此问题。

RenderObject
不处理分页符。您只能使用它将单个对象渲染到单个页面。您可以使用自定义页面大小使页面变得非常巨大

RenderPage
处理分页符。创建一个包含多个对象的文档,然后使用
RenderPage
绘制它。
此处可以看到使用
RenderPage
(用于不同目的)的示例:

如果需要,您可以从
FormattedDocument
中查询有关对象大小和位置的信息。

//
    <code>
        PdfDocument layoutDoc = new PdfDocument();
        PdfPage page = layoutDoc.AddPage();
        XGraphics gfx = CreatePageLayout(page);
        XFont font = new XFont("Verdana", 12);
    </code>
///合并左右面板 /// /// /// ///

公共静态void合并面板(Document、PdfDocument、leftPanelPdfDoc、XGraphics-gfx)
{
PdfPage page=null;
//左右面板的连接
//创建渲染器并准备(布局)文档
MigraDoc.Rendering.DocumentRenderer docRenderer=新的DocumentRenderer(migraDocument);
docRenderer.PrepareDocument();
//获取RightPanelDoc的页面计数
int rightPageCount=docRenderer.FormattedDocument.PageCount;
int leftPageCount=leftPanelPdfDoc.PageCount;
//循环以添加与rightPanel相等的leftPanel页面,并通过渲染合并
int指数=0;
做
{
//仅适用于单个左面板页面。
如果(索引==0)
{
渲染页面(gfx,索引+1);
索引++;
}
其他的
{
page=leftPanelPdfDoc.AddPage();
page.Size=PdfSharp.PageSize.A4;
gfx=CreatePageLayout(第页);
//呈现页面。请注意,页码以1开头。
渲染页面(gfx,索引+1);
索引++;
}
}
while(索引
但上面的这一个适用于单个左侧页面和响应右侧面板(页面添加到pdfsharp文档中,然后使用该gfx在其上呈现MigraDoc页面)。
但是,这可以改进,使左侧面板也先有多个页面,然后获取每个页面的gfx(XGraphics对象),并呈现右侧面板MigraDoc

我很想将其标记为“不清楚您在问什么”。格式不一致无助于理解问题。请确保在调用
PrepareDocument()之前设置了正确的页面宽度
.Hi,在当前的实现中,我只能添加单个页面,但是如果数据增加,那么如果数据大小超过一页,我也必须分页符,因为我“渲染段落对象”,所以它会在右面板溢出。此问题在migradoc中不存在,因为它会将附加数据添加到下一页,即分页符由它处理。但是单独使用migradoc生成这两个面板,然后连接为一个。可以这样做吗?您好,我尝试使用渲染页,但只有最后一页被渲染
/*页计数器*/int pageCount=docRenderer。对于mattedDocument.PageCount;PdfPage page=pdfDocument.AddPage();XGraphics gfx=CreatePageLayout(page);XRect rect=GetRect(idx);XGraphicsContainer container=gfx.BeginContainer(rect,A4Rect,XGraphicsUnit.Point);//呈现页面.docRenderPage.RenderPage(gfx,idx+1);//弹出上一个图形状态gfx.EndContainer(容器)
我看到了这个例子,其中他们使用了两个pdf文档。但在我的例子中,我在运行时生成pdf文件。一个是PdfDocument,另一个是MirgraDoc文档。那么我可以使用链接中所示的这种技术来组合这两个文档并获得所需的布局吗?回复第一条注释:代码中没有循环,因此只需调用一次
RenderPage()
只绘制一个页面。第二条评论:总是有一些选项使事情变得更复杂。您可以使用PDFsharp创建一个文档并保存到流,使用MigraDoc创建另一个文档并保存到流,然后
     /// <summary>
            /// Merge Left and Right Panels
            /// </summary>
            /// <param name="rightPanelMigraDoc"></param>
            /// <param name="leftPanelPdfDoc"></param>
            /// <param name="gfx"></param>
    <code>
            public static void MergePanels(Document migraDocument, PdfDocument leftPanelPdfDoc, XGraphics gfx)
            {
                PdfPage page = null;

                //concatenation of Left and Right Panels 
                // Create a renderer and prepare (layout) the Migradoc document
                MigraDoc.Rendering.DocumentRenderer docRenderer = new DocumentRenderer(migraDocument);
                docRenderer.PrepareDocument();

                //get pagecount of the rightpanelMigraDoc
                int rightPageCount = docRenderer.FormattedDocument.PageCount;
                int leftPageCount = leftPanelPdfDoc.PageCount;
                // Loop to add leftPanel pages equal to rightPanel and Merge by rendering
                int index = 0;
                do
                {
                    //for single left panel page only.
                    if (index == 0)
                    {
                        docRenderer.RenderPage(gfx, index + 1);
                        index++;
                    }
                    else
                    {
                        page = leftPanelPdfDoc.AddPage();
                        page.Size = PdfSharp.PageSize.A4;
                        gfx = CreatePageLayout(page);
                        // Render the page. Note that page numbers start with 1.
                        docRenderer.RenderPage(gfx, index + 1);
                        index++;
                    }
                }
                while (index < rightPageCount);
            }
    </code>