Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image layout options #210

Closed
stefanstranger opened this issue Feb 21, 2024 · 8 comments
Closed

Image layout options #210

stefanstranger opened this issue Feb 21, 2024 · 8 comments

Comments

@stefanstranger
Copy link

I'm using the PowerShell Module PSWriteOffice for Word document creation and I'm trying to insert an image using the following code:

elseif ($Paragraph.Text -like "<TODO: Insert  Image>") {
            $Paragraph.Text = ''
            $Paragraph.AddImage("C:\temp\image.png")
            $Paragraph.ParagraphAlignment = 'Center'
            $Paragraph.IndentationBefore = 1
            $Paragraph.IndentationAfter = 1
        }

But I need to apply the following layout configuration.

image

How can this be done programmatically?

Regards,
Stefan Stranger

@PrzemyslawKlys
Copy link
Member

Hi,

I need to update PSWriteOffice to newest library version, because we already support those layouts in newest one

var pargraphWithImage = paragraph.AddImage(file, 100, 100, WrapTextImage.InLineWithText, "Przemek and Kulek on an image");

In PowerShell it will be like

$pargraphWithImage = $paragraph.AddImage(file, 100, 100, [WrapTextImage]::InLineWithText, "Przemek and Kulek on an image");

Probably the WrapTextImage will need a full type or using to work. New version also allows switching between TextWrappings

image

So as soon as the image is added you can also change it on the fly. I'm neglegtic powershell version a bit, but OfficeIMO alone is hard to manage ;)

@stefanstranger
Copy link
Author

Hi Przemysław,

Thanks for your fast response. Do I understand I need to wait for you to update the PowerShell module to use the latest library?

When I try to do it using the existing library I get the following error:

$Paragraph.Image.WrapText = 'BehindText'
SetValueInvocationException: Exception setting "WrapText": "This needs to be implemented properly!"

Regards,
Stefan Stranger

@PrzemyslawKlys
Copy link
Member

Ye, I'll try to release it tonight. I've not updated the library for a bit. Also keep in mind that when you switch between different Wraps (Inline vs Anchor) it looses certain prroperties. Inline has minimal set properties because it's kind of bound to paragraph, and the rest is basically anchored, so you would need to play with positioning after doing changes like that.

@PrzemyslawKlys
Copy link
Member

I've released new version - you can try it out.

@stefanstranger
Copy link
Author

@PrzemyslawKlys

I tried to update the PSWriteOffice module via the PowerShell gallery but got this error message:
Install-Package: Authenticode issuer 'CN=Przemysław Kłys EVOTEC, O=Przemysław Kłys EVOTEC, L=Mikołów, C=PL' of
the new module 'PSWriteOffice' with version '0.2.0' from root certificate authority
'CN=DigiCert Trusted Root G4, OU=www.digicert.com, O=DigiCert Inc, C=US' is not matching with
the authenticode issuer 'CN=Przemysław Kłys EVOTEC, O=Przemysław Kłys EVOTEC, L=Katowice,
S=Śląskie, C=PL' of the previously-installed module 'PSWriteOffice' with version '0.1.0' from
root certificate authority 'CN=DigiCert Assured ID Root CA, OU=www.digicert.com, O=DigiCert
Inc, C=US'. If you still want to install or update, use -SkipPublisherCheck parameter.

@PrzemyslawKlys
Copy link
Member

Install-Module PSWriteOffice -Force -Verbose -SkipPublisherCheck

I changed certificate some time ago, as my last one expired and there's no other way around it.

@stefanstranger
Copy link
Author

Ok I did the use the -skippublishercheck option to resolve this.

Should I ask internally on how above error can be fixed?

Stefan Stranger
[MSFT]

@PrzemyslawKlys
Copy link
Member

PrzemyslawKlys commented Feb 22, 2024

The error above is not really an error. Once you install module with certain certificate it's there to protect you a bit from changes or dropping non-signed versions. However when my 3 year certificate expired and it changes - that is the cert warning you get. I wish it was easier, but you can either delete the old versions and do install-module without skippublishercheck, or use skippublishercheck. Otherwise that's the warning you get.

In theory maybe if the whole issuer/subject name would be the same it could work, but DigiCert gave me new data so it's a mismatch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants