gpt4 book ai didi

scale - PDFsharp - 更改页面大小和缩放内容

转载 作者:行者123 更新时间:2023-12-04 01:40:10 52 4
gpt4 key购买 nike

是否可以从例如缩放页面? A2 到 A1 与 PDFsharp?我可以通过大小、宽度和高度来设置页面的大小。但是如何缩放页面的内容呢?

最佳答案

根据 Vive 的评论和那里提供的链接,这里有一个使用 C# 将大小调整为 A4 的示例:

您必须包括:

    using PdfSharp.Pdf;
using PdfSharp.Drawing;
using PdfSharp;

然后:

    // resize this  file from A3 to A4
string filename = @"C:\temp\A3.pdf";

// Create the new output document (A4)
PdfDocument outputDocument = new PdfDocument();
outputDocument.PageLayout = PdfPageLayout.SinglePage;

XGraphics gfx;
XRect box;
// Open the file to resize
XPdfForm form = XPdfForm.FromFile(filename);

// Add a new page to the output document
PdfPage page = outputDocument.AddPage();

if (form.PixelWidth > form.PixelHeight)
page.Orientation = PageOrientation.Landscape;
else
page.Orientation = PageOrientation.Portrait;

double width = page.Width;
double height = page.Height;

gfx = XGraphics.FromPdfPage(page);
box = new XRect(0, 0, width, height);
gfx.DrawImage(form, box);

// Save the document...
string newfilename = @"c:\temp\resized.pdf";
outputDocument.Save(newfilename);

关于scale - PDFsharp - 更改页面大小和缩放内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47513689/

52 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com