PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 10:10 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Tue Mar 26, 2019 1:17 pm 
Offline

Joined: Wed Jul 19, 2017 1:51 pm
Posts: 8
Hello. I'm using PdfSharp to print an image to a PDF, and my goal would be to draw the image in parts, for multiple pages (since it's a big image, requires multiple A3 pages - my biggest printer).

I used the XGraphics DrawImage method with 2 XRect arguments, similar to the GDI methods, to draw the part of the image on the first page, move X coordinate on source, add a page and draw the next section until it's done.

Debuging the source code to understand why instead of doing what i though instead it repeated the entire image "reduced" on every page, i found a comment on the code of the XGraphicsPdfRenderer class (that is called by the DrawImage method of the XGraphics class) that says: "incomplete - srcRect not used".

I have no clue on how to alter this procedure to use the srcRect argument and get sections of the image based on that rectangle. The code currently is (of the PdfSharp version that i have):

Code:
public void DrawImage(XImage image, XRect destRect, XRect srcRect, XGraphicsUnit srcUnit)
{
    double x = destRect.X;
    double y = destRect.Y;
    double width = destRect.Width;
    double height = destRect.Height;
    string name = this.Realize(image);
    if (!(image is XForm)) { if (this.gfx.PageDirection == XPageDirection.Downwards) { AppendFormat("q {2:0.####} 0 0 -{3:0.####} {0:0.####} {4:0.####} cm {5} Do\nQ\n", x, y, width, height, y + height, name); } else { AppendFormat("q {2:0.####} 0 0 {3:0.####} {0:0.####} {1:0.####} cm {4} Do Q\n", x, y, width, height, name); } }
    else
    {
        BeginPage();
        XForm xForm = (XForm)image;
        xForm.Finish();
        PdfFormXObject pdfForm = Owner.FormTable.GetForm(xForm);
        double cx = width / image.PointWidth;
        double cy = height / image.PointHeight;
        if (cx != 0 && cy != 0) { if (this.gfx.PageDirection == XPageDirection.Downwards) { AppendFormat("q {2:0.####} 0 0 -{3:0.####} {0:0.####} {4:0.####} cm 100 Tz {5} Do Q\n", x, y, cx, cy, y + height, name); } else { AppendFormat("q {2:0.####} 0 0 {3:0.####} {0:0.####} {1:0.####} cm {4} Do Q\n", x, y, cx, cy, name); } }
    }
}


By looking at it is clear that in fact the argument is ignored; but i don't knwo enought of the AppendFormat or the Realize(image) method to change that. Any help?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 111 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group