Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Oct 31, 2018 8:43 am

Dear dahami,

We do understand your situation, however at present we don't find a good way to solve it due to its complexity.
Our Dev team is continuing finding a solution. And I have urged our Dev team and will follow the issue. Once there is any update, we will let you know.
Sincerely apologize for the inconvenience and thanks for your understanding.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Fri Nov 16, 2018 9:25 am

Dear dahami,

Glad to inform you the issue has been fixed in Spire.PDF Pack(Hot Fix) Version:4.11.8. And please add following code to make sure the image could be copied successfully.
Code: Select all
doc.PageSettings.Margins.All = 0;


Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Nov 19, 2018 7:09 am

i've apply hotfix but it doesn't solve my problem.

i just copied bunch of dll and add 'pdoc.PageSettings.Margins.All = 0;' on my constructor.

but still output is same as before.

after few attempt, i found source of problem.

i've restrict a region on my image and set specific location something like this

Code: Select all
            PdfDocument pdoc = new PdfDocument();
            pdoc.PageSettings.Margins.All = 0;
            PdfPageBase pgb = pdoc.Pages.Add(new System.Drawing.SizeF(842f,595f));

            PdfImage pdf_image = PdfImage.FromFile("img_source.png");

            PdfTemplate pdf_template2 = new PdfTemplate(731.186462f, 539.25f);

            pdf_template2.Graphics.DrawImage(pdf_image,new System.Drawing.RectangleF(0,0, 731.186462f, 539.25f));
            pdf_template2.Graphics.Flush();

            pgb.Canvas.DrawTemplate(pdf_template2, new System.Drawing.PointF(55.15678f, 27.75f));

            pdoc.SaveToFile("save.pdf",FileFormat.PDF);


but as you can see, it didn't work properly.

so i try modifiy my source a little bit
Code: Select all
            PdfPageBase pgb = pdoc.Pages.Add(new System.Drawing.SizeF(842f, 595f));

            PdfImage pdf_image = PdfImage.FromFile("img_source.png");

            PdfTemplate pdf_template2 = new PdfTemplate(731.186462f + 55.15678f, 539.25f + 27.75f);

            pdf_template2.Graphics.DrawImage(pdf_image, new System.Drawing.RectangleF(55.15678f, 0, 731.186462f, 539.25f));
            pdf_template2.Graphics.Flush();

            pgb.Canvas.DrawTemplate(pdf_template2, new System.Drawing.PointF(0, 27.75f));

            pdoc.SaveToFile("save.pdf", FileFormat.PDF);


but i think this approach isn't right.

for your information, i've add image source.

let me know if i was wrong or need to be update.

i'm really grateful your effort. thank you.

dahami
 
Posts: 21
Joined: Thu Jun 28, 2018 4:39 am

Mon Nov 19, 2018 10:11 am

Dear dahami,

Thanks for your information.
Below is my testing code:
Code: Select all
            PdfDocument doc = new PdfDocument();
            doc.PageSettings.Margins.All = 0;
            PdfPageBase page = doc.Pages.Add();
            PdfImage image = PdfImage.FromFile(@"F:\img_source.png");
            RectangleF rec = new RectangleF(5, 10, 300, 300);
            page.Canvas.DrawImage(image, rec);
            doc.SaveToFile("My testing code.pdf");

The image in the PDF could be copied correctly,attached are my results for your kind reference. As for your two cases, after testing I find there would be black rectangle on the left or right. I have posted the issue to our Dev team, if there is any question, we will let you know.

Besides, to help us ensure your issue would be fixed in all cases, please tell us following information:
1. What functions you would use and better to provide your full Spire code if you have.
2. Your OS and Region information, e.g. Win7 64bit, China/Chinese.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Nov 19, 2018 11:39 pm

i tried your code and i realized this is going to work if there aren't any PdfTemplate.

but i must have to using pdftemplate as 'Transform'(TranslateTransform,RotateTransform)
like this
Code: Select all
                   _rotated_main.Reset(new System.Drawing.SizeF(_rotated_main.Height, _rotated_main.Width)); //swap width,height
                            _rotated_main.Graphics.TranslateTransform(0, _rotated_main.Width);
                            _rotated_main.Graphics.RotateTransform(270);


about full source code, that's all about default save routine that i was post before

in addition to there are PdfUriAnnotation on the page, PdfGraphicsState for process to alpha
like this
Code: Select all
                            PdfGraphicsState state1 = cropTemplate.Graphics.Save();
                            if (!ma.colorMarkerFillColor.A.Equals(0))
                            cropTemplate.Graphics.SetTransparency((float)ma.colorMarkerFillColor.A / 255);
                            if (!ma.colorMarkerStrokeColor.A.Equals(0))
                                cropTemplate.Graphics.SetTransparency((float)ma.colorMarkerStrokeColor.A / 255);
....Draw routine
                            cropTemplate.Graphics.Restore(state1);


i've using Windows 10 pro 64bit, and develope 32bit program. my customer OS's is Windows 7 sp 1 32/64 over
Region and language is Korea/Korean

thanks

dahami
 
Posts: 21
Joined: Thu Jun 28, 2018 4:39 am

Tue Nov 20, 2018 12:08 am

i also using Template.Graphics.DrawString and DrawRectangle with region. but i think it isn't relate on this problem.

dahami
 
Posts: 21
Joined: Thu Jun 28, 2018 4:39 am

Tue Nov 20, 2018 2:00 am

Dear dahami,

Many thanks for your information.
I have transferred those information to our Dev team, we will let you know if there is any update.
We apologize for the inconvenience.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF